package net.dlz.example.service;

import net.dlz.example.domain.Application;
import net.dlz.example.domain.ApplicationExample;
import net.dlz.example.mapper.ApplicationMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ApplicationServiceImpl implements ApplicationService {
    @Autowired
    private ApplicationMapper applicationMapper;
    @Override
    public List<Application> findAllApplication() {
        return applicationMapper.selectByExample(new ApplicationExample());
    }

    @Override
    public int saveApplication(Application application) {
        if(StringUtils.isNotBlank(application.getApplicationId())){
            return applicationMapper.updateByPrimaryKey(application);
        }else {
            return applicationMapper.insert(application);
        }
    }

    @Override
    public Application findApplicationById(String id) {
        return applicationMapper.selectByPrimaryKey(id);
    }

    @Override
    public Application findApplicationByUserId(String userId) {
        return applicationMapper.findApplicationByUserId(userId);
    }

    @Override
    public List<Application> findAllApplication0() {
        return applicationMapper.findAllApplication0();
    }

    @Override
    public List<Application> findAllApplication1() {
        return applicationMapper.findAllApplication1();
    }

    @Override
    public Application findApplicationByUserId2(String userId) {
        return applicationMapper.findApplicationByUserId2(userId);
    }

}
